<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script src="./js/moment-with-locales.js"></script>
    <script>
      // 显示
      // format()
      console.log(moment().format());
      console.log(moment().format("DDDo, w, MMMM, Do, ZZ"));
      // 本地化
      moment.locale("zh-cn");
      console.log(moment().format("LLLL"));

      console.log(moment("2008").fromNow());

      let a = moment([2007, 0, 15]);
      let b = moment([2007, 0, 29]);
      console.log(a.from(b));

      console.log(moment("2008").toNow());
      a = moment([2007, 0, 15]);
      b = moment([2007, 0, 29]);
      console.log(a.to(b));

      console.log(moment().calendar());
      console.log(moment().calendar(moment([2024, 11, 10])));

      // diff
      a = moment([2007, 0, 29]);
      b = moment([2007, 0, 28]);
      console.log(a.diff(b, "days")); // 86400000

      // valueOf
      console.log(moment().valueOf(), +moment());

      // unix: 返回当前秒数，传统的返回的毫秒数
      console.log(moment().unix());

      // 获取当月的天数。
      console.log(moment().daysInMonth());

      // toDate
      console.log(moment().toDate());
      console.log(moment().toArray());
      console.log(moment().toObject());
    </script>
  </body>
</html>
